package project.controller;

import project.service.StudentService;
import project.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*
杨威
2021/9/16
14:49
*/
@WebServlet("/delete")
public class deleteController extends HttpServlet {
    StudentService studentService=new StudentServiceImpl();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String stuId = request.getParameter("stuId");
        int i = studentService.deleteStudent(Integer.valueOf(stuId));
        if(i>0){
            response.sendRedirect(request.getContextPath()+"/showAllStudentController");
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
